package com.sgb.kjwl.view.ui.adapter.pick;

import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.pick.TenderDictEntity3;
import com.sgb.kjwl.model.entity.pick.TenderInfoBasicEntity3;
import com.sgb.kjwl.view.ui.activity.pick.PhotoDownloadViewActivity;
import com.sgb.link.view.widget.ExpandedTextView;
import com.swgk.core.recyclerview.secondary.DescHolder;
import com.swgk.core.recyclerview.secondary.HeaderHolder;
import com.swgk.core.recyclerview.secondary.SectionedRecyclerViewAdapter;

import java.util.List;

public class PickDetailDictAdapter3 extends SectionedRecyclerViewAdapter<TenderInfoBasicEntity3, TenderDictEntity3, HeaderHolder, DescHolder, RecyclerView.ViewHolder> {

    private TextView contentView;
    private TextView expandView;
    private TextView expandTitle;
    private TextView signOrDelay;
    private Context context;
    private String title;
    private Boolean isChild;

    public PickDetailDictAdapter3(Context mContext, List<TenderInfoBasicEntity3> datas) {
        super(mContext, R.layout.item_pick_detial_header3, R.layout.item_pick_detial_desc3, datas);
        context = mContext;
    }

    public PickDetailDictAdapter3(Context mContext, List<TenderInfoBasicEntity3> datas,String title) {
        super(mContext, R.layout.item_pick_detial_header3, R.layout.item_pick_detial_desc3, datas);
        context = mContext;
        this.title = title;
    }

    @Override
    protected void onBindSectionHeaderViewHolder(HeaderHolder holder, int section, TenderInfoBasicEntity3 secondaryEntity) {
        holder.setBinding(BR.viewModel, secondaryEntity);
        TextView textView = holder.getItem().findViewById(R.id.head_title);
        if (secondaryEntity.getGroupName().contains("(") || secondaryEntity.getGroupName().contains("（")) {
            textView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
            isChild = true;
        } else {
            isChild = false;
            textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        }
    }

    @Override
    protected void onBindSectionFooterViewHolder(RecyclerView.ViewHolder holder, int section) {

    }

    @Override
    protected void onBindItemViewHolder(DescHolder holder, int section, int position, TenderDictEntity3 entity) {
        holder.setBinding(BR.viewModel, entity);
        expandTitle = holder.getItem().findViewById(R.id.content_title);
        View viewHint = holder.getItem().findViewById(R.id.view_hint);
        if(isChild){
            viewHint.setVisibility(View.VISIBLE);
        }else{
            viewHint.setVisibility(View.GONE);
        }

        if("无".equals(entity.getName())){
            expandTitle.setText(entity.getName());
        }else{
            expandTitle.setText(entity.getName()+"："+entity.getValue());
        }

    }

}